unit uTweakDialog;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons, uCore;

type
  TfrmTwex = class(TForm)
    pnlName: TPanel;
    pnlDescription: TPanel;
    pnlInfo: TPanel;
    lblName: TLabel;
    imgIcon: TImage;
    pnlText: TPanel;
    pnlCheck: TPanel;
    imgBackground: TImage;
    lblSoftware: TLabel;
    lblVersion: TLabel;
    lblProfileCaption: TLabel;
    lblProfile: TLabel;
    lblPublisherCaption: TLabel;
    lblPublisher: TLabel;
    ckbInput: TCheckBox;
    cbxInput: TComboBox;
    lblDescription: TLabel;
    imgSoftware: TImage;
    btnInstall: TBitBtn;
    btnClose: TBitBtn;
    CheckBox1: TCheckBox;
    procedure btnCloseClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure pAjustFormHeight;
    procedure WMNCLBUTTONDOWN(var Msg: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
    procedure WMNCLBUTTONUP(var Msg: TWMNCLButtonUp); message WM_NCLBUTTONUP;
  public
    { Public declarations }
  end;

var
  frmTwex: TfrmTwex;
  twxCore: TTwexCore;

implementation

{$R *.dfm}

procedure TfrmTwex.btnCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmTwex.CheckBox1Click(Sender: TObject);
begin
  pnlInfo.Visible := CheckBox1.Checked;
  pAjustFormHeight;
end;

procedure TfrmTwex.FormCreate(Sender: TObject);
begin
  twxCore := TTwexCore.Create;

  btnInstall.DoubleBuffered := False;
  btnClose.DoubleBuffered := False;
end;

procedure TfrmTwex.FormDestroy(Sender: TObject);
begin
  if (twxCore <> nil) then
    FreeAndNil(twxCore);
end;

procedure TfrmTwex.FormShow(Sender: TObject);
begin
  pAjustFormHeight;
end;

procedure TfrmTwex.pAjustFormHeight;
var
  itHeight: Integer;
  itI: Integer;
begin
  itHeight := 50;

  for itI := 0 to ComponentCount - 1 do
    if (Components[itI] is TPanel) then
      if (TPanel(Components[itI]).Parent = Self) then
        if (TPanel(Components[itI]).Visible) then
          itHeight := itHeight + TPanel(Components[itI]).Height;

  Self.ClientHeight := itHeight;
end;

procedure TfrmTwex.WMNCLBUTTONDOWN(var Msg: TWMNCLButtonDown);
begin
  if Msg.HitTest = HTHELP then
    Msg.Result := 0
  else
    inherited;
end;

procedure TfrmTwex.WMNCLBUTTONUP(var Msg: TWMNCLButtonUp);
begin
  if Msg.HitTest = HTHELP then
  begin
    Msg.Result := 0;
    twxCore.ShowAboutForm(Self);
  end
  else
    inherited;
end;

end.
